package util;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class HammingDist {
	

	public static int calc(Set<Object> m1, Set<Object> m2) {		
		int dist = 0;
		Set<Object> allKeys = new HashSet<Object>();
		allKeys.addAll(m1);
		allKeys.addAll(m2);
		
		for (Object key : allKeys) {
			if (!m1.contains(key) || !m2.contains(key)) {
				dist++;				
			}
		}
		return dist;
	}

	public static <T> int calcG(Set<T> m1, Set<T> m2) {		
		int dist = 0;
		Set<Object> allKeys = new HashSet<Object>();
		allKeys.addAll(m1);
		allKeys.addAll(m2);
		
		for (Object key : allKeys) {
			if (!m1.contains(key) || !m2.contains(key)) {
				dist++;				
			}
		}
		return dist;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		HashMap<String, Integer> m1 = new HashMap<String, Integer>();
		HashMap<String, Integer> m2 = new HashMap<String, Integer>();
		
		m1.put("Adam", 1);
		m1.put("ate", 1);
		m1.put("apple", 1);
		
		m2.put("Eve", 1);
		m2.put("ate", 1);
		m2.put("apple", 1);
		
//		System.out.println(HammingDist.calc(m1.keySet(), m2.keySet()));
		System.out.println(HammingDist.calcG(m1.keySet(), m2.keySet()));

	}

}

